package com.jrx.anytxn.param.utils;

import com.google.common.collect.Maps;
import com.jrx.anytxn.param.dto.aviator.TransactionDicInfoRes;

import java.util.*;
/**
 * @author
 */
public class TransactionDicInfoFunction {

    private TransactionDicInfoFunction() {
    }

    public static List<TransactionDicInfoRes> builtTransactionDicInfoList() {

        Map<String, String> bigTypeCodeMap = new LinkedHashMap<>();
        bigTypeCodeMap.put("R", "普通消费交易");
        bigTypeCodeMap.put("C", "取现交易");
        bigTypeCodeMap.put("I", "普通分期");
        bigTypeCodeMap.put("L", "专项分期");
        bigTypeCodeMap.put("S", "现金分期");
        bigTypeCodeMap.put("P", "还款交易");

        Map<String, String> smallTypeCodeMap = Maps.newHashMap();
        smallTypeCodeMap.put("R001", "网上消费");
        smallTypeCodeMap.put("R002", "门店消费");
        smallTypeCodeMap.put("C001", "取现交易");
        smallTypeCodeMap.put("I001", "窗口取现");
        smallTypeCodeMap.put("L001", "专项分期");
        smallTypeCodeMap.put("S001", "现金分期");
        smallTypeCodeMap.put("P001", "网上还款");

        List<TransactionDicInfoRes> transactionDicInfoList = new ArrayList<>();
        for (Map.Entry<String, String> entry : bigTypeCodeMap.entrySet()) {
            TransactionDicInfoRes fatherDto = new TransactionDicInfoRes();
            fatherDto.setCode(entry.getKey());
            fatherDto.setName(entry.getValue());
            fatherDto.setLevel(1);
            List<TransactionDicInfoRes> detailList = new ArrayList<>();
            for (Map.Entry<String, String> smallEntry : smallTypeCodeMap.entrySet()) {
                if (entry.getKey().equals(smallEntry.getKey().substring(0, 1))) {
                    TransactionDicInfoRes sonDto = new TransactionDicInfoRes();
                    sonDto.setCode(smallEntry.getKey());
                    sonDto.setName(smallEntry.getValue());
                    sonDto.setLevel(2);
                    sonDto.setFatherCode(entry.getKey());
                    detailList.add(sonDto);
                }
            }
            fatherDto.setDetailList(detailList);
            transactionDicInfoList.add(fatherDto);
        }

        return transactionDicInfoList;
    }
}



